<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://www.ufida.com/lfw" prefix="lfw" %>
<%@ taglib uri="http://www.ufida.com/multilang" prefix="ml" %>
<%@ taglib uri="http://www.ufida.com/lfwtool" prefix="lfwtool" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<html>
	<head>
		<lfw:base/>
		<lfw:head/>
		<lfw:import/>
		<script type='text/javascript' src='<%= "code/" + request.getParameter("pageId") %>'></script>
		<style>
			body{
				padding:0px;
				margin:0px;
				overflow:hidden;
				border:0px;
			}
			.logodiv{
				background:url('${NODE_IMAGE_PATH}/top/nc-logo.png');
				_background:none;
				width:201px;
				height:41px;
				margin-left:36px;
				_filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${ROOT_PATH}/${NODE_IMAGE_PATH}/top/nc-logo.png');
			}
			
			#bodydiv{
				height:100%;
				background:#94C6F9;
				_background:none;
				filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#94C6F9, EndColorStr=#FFFFFF);
				padding-bottom:10px;
				padding-right:10px;
				padding-left:10px;
			}
			.head_nav{
				text-decoration:none;
				color:#000000;
			}
		</style>
		
	</head>
	<body bottommargin="0" topmargin="0" leftmargin="0" rightmargin="0" scroll=no onload="pageBodyScript();">
		<div style="height:200">
			<lfw:pageModel className="nc.lfw.finance.main.WebBxMainPageModel">
				<div style="width:100%;height:100%;overflow:auto;height:200">
					<lfw:tree id="funnodeTree"/>
				</div>
			</lfw:pageModel>
		</div>
	</body>
	<script>
	/**
	 * openNode
	 * @param name 打开tabitem的funcode（功能注册编码）
	 * @param src iframe中的
	 * @param funcode 打开页面的pageID
	 * @param attrArr 自定义属性,例如{title:'',funProperty:''}
	 */
	function openNode(funcode, src, attrArr)
	{ 
		//cleanBillMsg();
		if(src == null) 
			return;
		src = window.corePath + "/" + src;
		var title = null;
		if(attrArr != null && attrArr.title != null)
			title = attrArr.title;
		else
			title = funcode;//默认显示的是功能注册编码
		
		//默认以tab多页签打开
		var	openmode = "2";
	 	// 增加节点点击频率
		//addFunNodeFrequency(funcode);
		
		switch(openmode){
			case "0":
				// 最多打开几个页签后提示(默认为5个)
				var openTabMax = null;
				if(attrArr != null && attrArr.openTabMax != null)
					openTabMax = attrArr.openTabMax;
				else
				 	openTabMax = 5;
				 	
				var tab = getComponent("pageTab"), items = tab.getTabItems(), count = items.length;
				for(var i = 0; i < count; i++)
				{
					// 如果已经打开过相同funcode的单据
					if(items[i].name == funcode)
					{
						// 说明已经打开过审批单据
						if(items[i].approveid){
			   				// 首先关闭审批单据
			   				tab.removeItemTab(i);
			   				// 打开新的单据
			   				var item = tab.createItem(funcode, title, true);
			   				tab.activeTab(tab.getItemIndex(item));
							item.getObjHtml().appendChild(getNodeFrame(funcode, src));
							delete(items[i].approveid);
							return;
						}
						else
						{
							tab.activeTab(tab.getItemIndex(items[i]));				
							return;
						}
					}
				}
				
				// 如果已经打开单据数超过设置的打开最大限度则进行提示
				if(count > openTabMax)
				{
					continueOpen.tab = tab;
					continueOpen.funcode = funcode;
					continueOpen.title = title;
					continueOpen.src = src;
					ConfirmDialogComp.showDialog("${ml:trans('yer_quickdesk001')}" + (count-1) + "${ml:trans('yer_quickdesk002')}", continueOpen, null, null, null);
				} 
				else 
				{
					var item1 = tab.createItem(funcode, title, true);
					// 如果打开的是审批单据则记录审批单据id
					if(attrArr != null && attrArr.approveid)
						item1.approveid = attrArr.approveid;
					tab.activeTab(tab.getItemIndex(item1));
					// 显示"加载图片"
					showLoadingDiv(item1.getObjHtml());
//					if(div != null)
//						showBillMsg();
					item1.getObjHtml().appendChild(getNodeFrame(funcode, src));
				}
				break;
			case "1":
				var tab = getComponent("pageTab");
				var items = tab.getTabItems();
				var count = items.length;
				if(count == 2){
					var iframe = items[1].getObjHtml().firstChild.firstChild;
					iframe.src = src;
					items[1].changeTitle(title);
					tab.activeTab(1);
				} else {
					var item1 = tab.createItem(funcode, title, true);
					tab.activeTab(1);
					var div = getNodeFrame(funcode,src);
					item1.getObjHtml().appendChild(div);
					//showBillMsg();
				}
				break;
			case "2":
				window.open(src, title, "toolbar=no,menubar=no,scrollbar=yes,resizable=yes,location=no,status=no,fullscreen=no");
				//showBillMsg();
				break;		
			default:
				break;
		}
	};
	</script>
</html>
